#ifndef RULE_H
#define RULE_H

#include "global.h"
#include <boost/shared_ptr.hpp>
#include <vector>

namespace fouine {

class Table;

class RuleImpl
{
  public:
    virtual Likelihood match(const String&, StrId start, StrLen length, const Table& table) const= 0;
    virtual Likelihood test_match(const String&) const { return -1.; };
    virtual ~RuleImpl();
};

class Rule
{

  public:
    Likelihood match(const String&, StrId start, StrLen length, const Table& table) const;
    Rule(const Rule&);
    Likelihood test_match(const String&) const;
    Rule(boost::shared_ptr<RuleImpl>);
    
    static Rule makeOrRule(const std::vector<RuleId>&);
    static Rule makeSeqRule(const std::vector<RuleId>&);
    static Rule makeRegexRule(const String& ptn);
    
  private:
    boost::shared_ptr<RuleImpl> _rule_impl;
};


}

#endif // RULE_H
